<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>MyPromise</title>
  </head>
  <body>
    <h1>MyPromise</h1>

    <script src="./MyPromise.js"></script>
    <script>
      const p1 = new MyPromise((resolve, reject) => {
        // resolve(100);
        // reject("error");
        setTimeout(() => {
          resolve("success"), 200;
        });
      });
      console.log(p1);

      const p11 = p1.then((data1) => {
        console.log("data1", data1);
        return data1 + 1;
      });
      const p22 = p11.then((data2) => {
        console.log("data2", data2);
        return data2 + 2;
      });
      const p13 = p12.catch((err) => console.log(err));

      // const p2 = MyPromise.resolve(200);
      // const p3 = MyPromise.reject("错误信息...");
      // const p4 = MyPromise.all([p1, p2]);
      // const p5 = MyPromise.race([p1, p2]);
    </script>
  </body>
</html>
